package com.starleague.battletech.unit.jpa.appengine;

import java.util.Map;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.MappedSuperclass;

import com.starleague.battletech.jpa.appengine.BattletechPointsGae;
import com.starleague.battletech.unit.IBattletechUnitHitLocation;
import com.starleague.jpa.appengine.GaeDao;

@MappedSuperclass
public abstract class BattletechUnitHitLocationGae
        extends GaeDao
        implements IBattletechUnitHitLocation
{
    @Embedded
    @AttributeOverrides({
            @AttributeOverride(name = "currentPoints",
                               column = @Column(name = "currentArmorHitPoints")),
            @AttributeOverride(name = "maximumPoints",
                               column = @Column(name = "maximumArmorHitPoints")) })
    private BattletechPointsGae armorHitPoints;

    @Embedded
    @AttributeOverrides({
            @AttributeOverride(name = "currentPoints",
                               column = @Column(name = "currentInternalStructureHitPoints")),
            @AttributeOverride(name = "maximumPoints",
                               column = @Column(name = "maximumInternalStructureHitPoints")) })
    private BattletechPointsGae internalStructureHitPoints;

    protected BattletechUnitHitLocationGae(int armorHitPoints,
                                           int internalStructureHitPoints)
    {
        this.armorHitPoints = new BattletechPointsGae(armorHitPoints);
        this.internalStructureHitPoints = new BattletechPointsGae(internalStructureHitPoints);
    }

    protected BattletechUnitHitLocationGae()
    {
        //
    }

    @Override
    public BattletechPointsGae getArmorHitPoints()
    {
        return this.armorHitPoints;
    }

    protected void setArmorHitPoints(BattletechPointsGae armorHitPoints)
    {
        this.armorHitPoints = armorHitPoints;
    }

    @Override
    public BattletechPointsGae getInternalStructureHitPoints()
    {
        return this.internalStructureHitPoints;
    }

    protected void setInternalStructureHitPoints(BattletechPointsGae internalStructureHitPoints)
    {
        this.internalStructureHitPoints = internalStructureHitPoints;
    }

    @Override
    public Map<String, Object> infoProperties()
    {
        Map<String, Object> infoPropertyMap = super.infoProperties();
        infoPropertyMap.put("armorHitPoints", this.armorHitPoints);
        infoPropertyMap.put("internalStructureHitPoints", this.internalStructureHitPoints);
        return infoPropertyMap;
    }
}
